using SheLife.Domain.Entities;

namespace SheLife.Infrastructure.Repositories
{
    /// <summary>
    /// 系统用户仓储接口
    /// </summary>
    public interface ISystemUserRepository : IRepository<SystemUser>
    {
        Task<SystemUser?> GetByUsernameAsync(string username);
        Task<SystemUser?> GetByEmailAsync(string email);
        Task<IEnumerable<SystemUser>> GetAllPagedAsync(int page = 1, int pageSize = 20);
        Task<int> GetTotalCountAsync();
        Task<int> GetActiveCountAsync();
        Task<IEnumerable<SystemUser>> GetByDateRangeAsync(DateTime startDate, DateTime endDate);
        Task<IEnumerable<SystemUser>> GetActiveByDateRangeAsync(DateTime startDate, DateTime endDate);
    }

    /// <summary>
    /// 系统菜单仓储接口
    /// </summary>
    public interface ISystemMenuRepository : IRepository<SystemMenu>
    {
        Task<SystemMenu?> GetByCodeAsync(string code);
        Task<IEnumerable<SystemMenu>> GetByParentIdAsync(Guid? parentId);
        Task<IEnumerable<SystemMenu>> GetByIdsAsync(IEnumerable<Guid> ids);
    }

    /// <summary>
    /// 角色菜单仓储接口
    /// </summary>
    public interface IRoleMenuRepository : IRepository<RoleMenu>
    {
        Task<bool> IsRoleHasMenuAsync(Guid roleId, Guid menuId);
        Task<bool> IsRoleHasMenuAsync(IEnumerable<Guid> roleIds, Guid menuId);
        Task<IEnumerable<SystemMenu>> GetRoleMenusAsync(Guid roleId);
        Task<IEnumerable<SystemMenu>> GetByRoleIdsAsync(IEnumerable<Guid> roleIds);
        Task<RoleMenu?> GetRoleMenuAsync(Guid roleId, Guid menuId);
    }

    /// <summary>
    /// 用户权限仓储接口
    /// </summary>
    public interface IUserPermissionRepository : IRepository<UserPermission>
    {
        Task<bool> IsUserHasPermissionAsync(Guid userId, Guid permissionId);
        Task<IEnumerable<SystemPermission>> GetUserPermissionsAsync(Guid userId);
        Task<UserPermission?> GetUserPermissionAsync(Guid userId, Guid permissionId);
    }

    /// <summary>
    /// 用户角色仓储接口
    /// </summary>
    public interface IUserRoleRepository : IRepository<UserRole>
    {
        Task<bool> IsUserHasRoleAsync(Guid userId, Guid roleId);
        Task<IEnumerable<SystemRole>> GetUserRolesAsync(Guid userId);
        Task<UserRole?> GetUserRoleAsync(Guid userId, Guid roleId);
    }

    /// <summary>
    /// 角色权限仓储接口
    /// </summary>
    public interface IRolePermissionRepository : IRepository<RolePermission>
    {
        Task<bool> IsRoleHasPermissionAsync(Guid roleId, Guid permissionId);
        Task<IEnumerable<SystemPermission>> GetRolePermissionsAsync(Guid roleId);
        Task<RolePermission?> GetRolePermissionAsync(Guid roleId, Guid permissionId);
    }
}